package reflect;

import reflect.annotations.AutoRunClass;
import reflect.annotations.AutoRunMethod;

import java.lang.reflect.Method;
import java.util.Scanner;
/**
 * 在此方法的基础上要求调用@AutoRunMethod标注的方法执行若干次
 * 次数有注解参数决定
 */
public class Test3 {
    public static void main(String[] args)throws Exception {
       Scanner scanner = new Scanner(System.in);
        System.out.println("说");
        String classNAme = scanner.nextLine();
        Class cls = Class.forName("reflect.Person");
        if (cls.isAnnotationPresent(AutoRunClass.class)){
            Object obj = cls.newInstance();
            Method[] methods = cls.getDeclaredMethods();
            for (Method method:methods){
                if (method.isAnnotationPresent(AutoRunMethod.class)){
                    AutoRunMethod arm = method.getAnnotation(AutoRunMethod.class);
                    int value = arm.value();
                    for (int i=0;i<value;i++){
                        method.invoke(obj);
                    }
                }
            }
        }
    }
}
